package com.plian.system.wrapper.im;

import com.plian.system.dto.im.ProjectInfoDTO;
import com.plian.system.entity.im.ProjectInfo;
import com.plian.system.mybatis.support.BaseWrapper;
import com.plian.system.vo.im.ProjectInfoVO;
import com.plian.system.wrapper.util.CacheWrapperUtil;
import com.plian.system.wrapper.util.WrapperUtil;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import static com.plian.system.wrapper.util.WrapperConstant.*;

/**
 * @description:
 * @author: gangan
 * @create: 2020-04-23 14:14
 */
@Mapper(componentModel = SPRING, uses = {CacheWrapperUtil.class, WrapperUtil.class})
public interface ProjectInfoWrapper extends BaseWrapper<ProjectInfo, ProjectInfoDTO, ProjectInfoVO> {

    /**
     * Entity转VO
     *
     * @param entity /
     * @return /
     */
    @Override
    @Mappings(value = {
            @Mapping(source = "investmentCompanyId", target = "investmentCompanyId", qualifiedByName = STR_NULL_TO_EMPTY),
            @Mapping(source = "investmentCompanyId", target = "investmentCompanyName", defaultValue ="" ),
            @Mapping(source = "investmentCompanyRankId", target = "investmentCompanyRankName", qualifiedByName = DICT_CODE_TO_NAME),
            @Mapping(source = "projectNatureId", target = "projectNatureName", qualifiedByName = DICT_CODE_TO_NAME),
            @Mapping(source = "subordinateGroupId", target = "subordinateGroupName", qualifiedByName = ORG_ID_TO_NAME),
            @Mapping(source = "fillingUnitId", target = "fillingUnitName", qualifiedByName = ORG_ID_TO_NAME),
            @Mapping(source = "fundSource", target = "fundSourceName", qualifiedByName = DICT_CODE_TO_NAME),

            @Mapping(source = "isAvailable", target = "isAvailableName", qualifiedByName = IS_OR_NO),
            @Mapping(source = "isLocal", target = "isLocalName", qualifiedByName = IS_OR_NO),
            @Mapping(source = "isStrategic", target = "isStrategicName", qualifiedByName = IS_OR_NO),
            @Mapping(source = "isPlan", target = "isPlanName", qualifiedByName = IS_OR_NO),
            @Mapping(source = "isNegativeProject", target = "isNegativeProjectName", qualifiedByName = IS_OR_NO),
            @Mapping(source = "isImportant", target = "isImportantName", qualifiedByName = IS_OR_NO),
            @Mapping(source = "projectType", target = "projectTypeName", qualifiedByName = DICT_CODE_TO_NAME),

            @Mapping(source = "isKeynoteProject", target = "isKeynoteProjectName", qualifiedByName = IS_OR_NO),
            @Mapping(source = "isSpecialSupervise", target = "isSpecialSuperviseName", qualifiedByName = IS_OR_NO),
            @Mapping(source = "isMainBusiness", target = "isMainBusinessName", qualifiedByName = IS_OR_NO),
            @Mapping(source = "isLastYearFirstQuarter", target = "isLastYearFirstQuarterName", qualifiedByName = IS_OR_NO),
            @Mapping(source = "isLastProvinceKeynote", target = "isLastProvinceKeynoteName", qualifiedByName = IS_OR_NO),
            @Mapping(source = "isLastCityKeynote", target = "isLastCityKeynoteName", qualifiedByName = IS_OR_NO),
            @Mapping(source = "isTechnologyChange", target = "isTechnologyChangeName", qualifiedByName = IS_OR_NO),




    })
    ProjectInfoVO entityToVO(ProjectInfo entity);

}
